import EncryptStatus from "@/types/encryptStatus";
import notice from "@/utils/notice";
import ResUtil from "@/utils/resUtil";
import AesUtil from "@/utils/secret/aesUtil";
import type { AxiosResponse } from "axios";

function decrypt(res: AxiosResponse<any, any>){
    if(res.headers[EncryptStatus.encrypt]=="true"){//如果开启了加密
        res.data=JSON.parse( AesUtil.decrypt(res.data,AesUtil.getKeyByTime(res.headers["date"])));
      } 
      let isSuccess = ResUtil.isSuccess(res);
      if (isSuccess) {
        if (res.config.method != "get") {
          if (res.data.message) notice.success(res.data.message);
        }
      } else {
        let msg = ResUtil.getMessage(res);
        if (msg) notice.error(msg);
      }
      return res;
}